<!-- 
  商品销售汇总明细
-->
<template>
  <a-drawer :open="visible" title="商品销售汇总明细" @close="onClose">
    <template #closeIcon>
      <div class="express-bar"></div>
      <div class="express-btn">
        <CloseCircleOutlined :size="32" @click="onClose" />
      </div>
    </template>
    <a-card class="smart-margin-top10" size="small" :tab-list="tabList" :active-tab-key="activeKey" @tabChange="(key) => (activeKey = key)">
      <template #customTab="{ tab }">
        <span class="ant-card-head-title" :style="compactModeClass">
          {{ tab }}
        </span>
      </template>
      <template v-if="activeKey === 'sale'">
        <GoodsSaleTable :row="options" />
      </template>
      <template v-if="activeKey === 'return'">
        <GoodsReturnTable :row="options" />
      </template>
    </a-card>
    <template #footer>
      <a-button @click="onClose">取消</a-button>
    </template>
  </a-drawer>
</template>

<script setup lang="ts">
import GoodsSaleTable from './goods-sale-table.vue'
import GoodsReturnTable from './goods-return-table.vue'
const compactModeClass = inject('compactModeClass')
defineExpose({
  showDrawer
})
const emit = defineEmits(['refresh'])

// --------------------- Drawer 显示与隐藏 ---------------------
// 是否展示
const visible = ref(false)
// 详情
const options = ref({})
// 详情tab
const activeKey = ref('sale')
const tabList = [
  {
    key: 'sale',
    tab: '商品销售明细'
  },
  {
    key: 'return',
    tab: '商品退货明细'
  }
]

function showDrawer(item) {
  options.value = item
  visible.value = true
}

const onClose = () => {
  visible.value = false
}
</script>
